package paquete;

import com.mountainreacher.chickenwinner.R;

import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;

public class Music {

	// Nombres de sonidos
	public static final int SOUND_IDS[] = {};
	private final float VOLUME = 1f;

	private SoundPool soundPool;
	private int[] soundIDs;
	private int selected;
	private int numberLoadedSounds;
	
	private MediaPlayer mediaPlayer;

	public Music(Context context) {

//		soundPool = new SoundPool(10, AudioManager.STREAM_ALARM, 0);
//		soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
//			@Override
//			public void onLoadComplete(SoundPool soundPool, int sampleId,
//					int status) {
//				numberLoadedSounds ++;
//			}
//		});
//
//		soundIDs = new int[SOUND_IDS.length];
//		for (int i = 0; i < SOUND_IDS.length; i++) {
//			soundIDs[i] = soundPool.load(contex, SOUND_IDS[i], 1);
//		}
		
		mediaPlayer = MediaPlayer.create(context, R.raw.im_chicken);
		mediaPlayer.setLooping(true);

	}

	public boolean playSound() {
//		if (isReadyToPlay()) {
//			soundPool.play(soundIDs[selected], VOLUME, VOLUME, 1, 0, 1f);
//			return true;
//		}
		mediaPlayer.start();
		return true;
	}

	public void autoPause() {
//		soundPool.autoPause();
		mediaPlayer.release();
	}
	
	public boolean isReadyToPlay() {
		return numberLoadedSounds == soundIDs.length;
	}
	
	public void destroy() {
		autoPause();
		soundPool.release();
		soundPool = null;
		soundIDs = null;
	}
}
